home *** CD-ROM | disk | FTP | other *** search
/ Robotics & Artificial Int…3 (Professional Edition) / Robotics & Artificial Intelligence Tools 2003 (Professional Edition).iso / neural network tool and application / nsinstall.exe / data1.cab / CustomSolutionWizard_Files / Examples / VBExample / VBExample.frm (.txt) next >
Encoding:
Visual Basic Form  |  2002-03-08  |  2.7 KB  |  69 lines

  1. VERSION 5.00
  2. Begin VB.Form Form1 
  3.    Caption         =   "Form1"
  4.    ClientHeight    =   3195
  5.    ClientLeft      =   60
  6.    ClientTop       =   345
  7.    ClientWidth     =   4680
  8.    LinkTopic       =   "Form1"
  9.    ScaleHeight     =   3195
  10.    ScaleWidth      =   4680
  11.    StartUpPosition =   3  'Windows Default
  12.    Begin VB.CommandButton Command1 
  13.       Caption         =   "Command1"
  14.       Height          =   1215
  15.       Left            =   720
  16.       TabIndex        =   0
  17.       Top             =   600
  18.       Width           =   3255
  19.    End
  20. Attribute VB_Name = "Form1"
  21. Attribute VB_GlobalNameSpace = False
  22. Attribute VB_Creatable = False
  23. Attribute VB_PredeclaredId = True
  24. Attribute VB_Exposed = False
  25. Private Sub Command1_Click()
  26.     'Define an input data array using the exclusive-or data
  27.     Dim inputData(0 To 1, 0 To 3)  As Variant
  28.     inputData(0, 0) = -1!
  29.     inputData(0, 1) = -1!
  30.     inputData(0, 2) = 1!
  31.     inputData(0, 3) = 1!
  32.     inputData(1, 0) = -1!
  33.     inputData(1, 1) = 1!
  34.     inputData(1, 2) = -1!
  35.     inputData(1, 3) = 1!
  36.     'Define a desired data array using the exclusive-or data
  37.     Dim desiredData(0 To 0, 0 To 3) As Variant
  38.     desiredData(0, 0) = -1!
  39.     desiredData(0, 1) = 1!
  40.     desiredData(0, 2) = 1!
  41.     desiredData(0, 3) = -1!
  42.     'Create and new neural network object of the type NSLearningNetwork
  43.     Dim nn As New NSLearningNetwork
  44.     'Set the pathName to the generated neural network DLL
  45.     nn.dllPathName = "C:\Program Files\NeuroSolutions 4\Wizards\CustomSolutionWizard\Examples\DLL\MLP.dll"
  46.     'Set the pathName to the weights file saved by the Custom Solution Wizard
  47.     nn.loadWeights "C:\Program Files\NeuroSolutions 4\Wizards\CustomSolutionWizard\Examples\DLL\MLP.nsw"
  48.     'Set the input data defined above as the input data
  49.     nn.inputData = inputData
  50.     'Set the desired data defined above as the desired data
  51.     nn.desiredData = desiredData
  52.     'Train the neural network for 100 epochs
  53.     nn.train 100
  54.     'Get the network response (output)
  55.     Dim networkOutput As Variant
  56.     networkOutput = nn.getResponse
  57.     'Display the network output in a message box
  58.     Dim outputString As String
  59.     outputString = ""
  60.     Dim exemplarNum As Integer, outputNum As Integer
  61.     For exemplarNum = LBound(networkOutput, 1) To UBound(networkOutput, 1)
  62.         For outputNum = LBound(networkOutput, 2) To UBound(networkOutput, 2)
  63.             outputString = outputString & "Output(" & exemplarNum & ", " & outputNum & ") = " & networkOutput(exemplarNum, outputNum) & Chr(13) & Chr(10)
  64.         Next outputNum
  65.     Next exemplarNum
  66.     MsgBox outputString
  67.     Set nn = Nothing
  68. End Sub
  69.